<%@ page import="com.example.demo_text.GradeDAO" %>
<%@ page import="com.example.demo_text.Grade" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    // 获取成绩列表
    List<Grade> grades = GradeDAO.getAllGrades(); // 假设已实现该方法
%>
<html>
<head>
    <title>成绩管理</title>
    <style>
        /* 全局样式（与 AdmitHome.jsp 保持一致） */
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Segoe UI', 'PingFang SC', 'Microsoft Yahei', sans-serif;
            background: linear-gradient(135deg, #e0f7fa, #f3e5f5);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 40px 20px;
            color: #333;
        }

        .card {
            background: white;
            width: 100%;
            max-width: 800px;
            padding: 30px 25px;
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
            transition: all 0.3s ease;
            text-align: center;
        }

        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
        }

        h2 {
            text-align: center;
            margin-bottom: 24px;
            font-weight: 600;
            color: #374151;
        }

        .table-container {
            overflow-x: auto;
            margin-top: 20px;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            min-width: 600px;
        }

        th, td {
            padding: 12px 15px;
            border-bottom: 1px solid #e5e7eb;
            text-align: left;
        }

        th {
            background-color: #f9fafb;
            font-weight: 600;
            color: #1f2937;
        }

        tr:hover {
            background-color: #f3f4f6;
        }

        .back-link {
            display: inline-block;
            margin-top: 20px;
            color: #3498db;
            text-decoration: underline;
            font-size: 14px;
        }

        .back-link:hover {
            color: #2980b9;
        }
    </style>
</head>
<body>

<div class="card">
    <h2>📊 学生成绩管理</h2>

    <div class="table-container">
        <table>
            <thead>
            <tr>
                <th>学生ID</th>
                <th>课程ID</th>
                <th>成绩</th>
                <th>更新时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <% for (Grade grade : grades) { %>
            <tr>
                <td><%= grade.getStudentId() %></td>
                <td><%= grade.getCourseId() %></td>
                <td><%= grade.getScore() %></td>
                <td><%= grade.getUpdateTime() %></td>
                <td>
                    <a href="editGrade.jsp?student_id=<%= grade.getStudentId() %>&course_id=<%= grade.getCourseId() %>">编辑</a>
                    <a href="#" style="color: red; margin-left: 10px;">删除</a>
                </td>
            </tr>
            <% } %>
            </tbody>
        </table>
    </div>

    <a href="AdmitHome.jsp" class="back-link">返回管理员主页</a>
</div>

</body>
</html>
